package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.client.LoadBalanceDemoClient;
import org.example.client.ProductClient;
import org.example.client.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ConsumerController {

    @Autowired
    UserClient userClient;
    @Autowired
    ProductClient productClient;
    @Autowired
    LoadBalanceDemoClient loadBalanceDemoClient;

    @GetMapping("/getUserNameById")
    public String getUserNameById(@RequestParam("userId") String userId){
        log.info("userId:{}",userId);
        return userClient.getUserNameById(userId);
    }

    @GetMapping("/getProductNameById")
    public String getProductNameById(@RequestParam("productId") String productId){
        return productClient.getProductNameById(productId);
    }

    @GetMapping("/getProviderInfo")
    public String getProviderInfo(){
        return loadBalanceDemoClient.getProviderInfo();
    }
}
